from django.db import models


class ServerHealth(models.Model):
    """服务器健康度表"""
    systemSN = models.CharField(max_length=64, null=True, blank=True, unique=True, verbose_name="资产SN")
    manageIp = models.CharField(max_length=255, null=True, blank=True, verbose_name="管理IP")
    ipmi = models.CharField(max_length=128, null=True, blank=True, verbose_name="带外IP")
    dataCenter = models.CharField(max_length=128, null=True, blank=True, verbose_name="机房")
    rackBuilding = models.CharField(max_length=128, null=True, blank=True, verbose_name="所属楼栋")
    rackFloor = models.CharField(max_length=128, null=True, blank=True, verbose_name="所属楼层")
    rackModule = models.CharField(max_length=128, null=True, blank=True, verbose_name="所属模块")
    rackCode = models.CharField(max_length=128, null=True, blank=True, verbose_name="所属机柜号")
    uLocationStart = models.CharField(max_length=128, null=True, blank=True, verbose_name="起始U位")
    uLocationEnd = models.CharField(max_length=128, null=True, blank=True, verbose_name="终止U位")
    userAccount = models.CharField(max_length=128, null=True, blank=True, verbose_name="使用人")
    userProductLine = models.CharField(max_length=128, null=True, blank=True, verbose_name="使用人产线")
    userDivision = models.CharField(max_length=128, null=True, blank=True, verbose_name="使用人BG/BU")
    model = models.CharField(max_length=128, null=True, blank=True, verbose_name="型号")
    manu = models.CharField(max_length=128, null=True, blank=True, verbose_name="厂商")
    warrantySince = models.DateField(null=True, verbose_name="维保开始日期")
    warrantyEnd = models.DateField(null=True, verbose_name="维保终止日期")
    arrivalDate = models.DateField(null=True, verbose_name="到货日期")

    remarks = models.CharField(max_length=2048, null=True, blank=True, verbose_name="备注")
    health = models.CharField(max_length=128, null=True, blank=True, verbose_name="健康度")
    healthScore = models.FloatField(null=True, verbose_name="健康度分数")
    lockStatus = models.CharField(max_length=128, null=True, blank=True, verbose_name="锁定状态")
    calculateTime = models.DateTimeField(null=True, verbose_name="计算时间")
    faultFrequency = models.CharField(max_length=128, null=True, blank=True, verbose_name="故障频次")
    lifeTime = models.CharField(max_length=128, null=True, blank=True, verbose_name="寿命期")
    expertise = models.CharField(max_length=2048, null=True, blank=True, verbose_name="专家经验")

    createAt = models.DateTimeField(auto_now=True, verbose_name="创建时间")
    updateAt = models.DateTimeField(auto_now_add=True, verbose_name="更新时间")
    isDeleted = models.IntegerField(default=0)

    class Meta:
        managed = True
        db_table = 'ServerHealth'


class ExpertiseHealthList(models.Model):
    """专家经验列表"""
    xid = models.CharField(max_length=128, null=True, blank=True, verbose_name="_XID")
    expertise = models.CharField(max_length=2048, null=True, blank=True, verbose_name="专家经验")
    health = models.CharField(max_length=128, null=True, blank=True, verbose_name="健康度")

    createAt = models.DateTimeField(auto_now=True, verbose_name="创建时间")
    updateAt = models.DateTimeField(auto_now_add=True, verbose_name="更新时间")
    isDeleted = models.IntegerField(default=0)

    class Meta:
        managed = True
        ordering = ['-createAt']
        db_table = 'ExpertiseHealthList'


class HealthLevel(models.Model):
    """健康度等级"""
    score = models.CharField(max_length=128, null=True, blank=True, verbose_name="健康度分数")
    healthLevel = models.CharField(max_length=128, null=True, blank=True, verbose_name="健康度等级")
    startScore = models.IntegerField(null=True, verbose_name="起始分")
    endScore = models.IntegerField(null=True, verbose_name="终止分")

    createAt = models.DateTimeField(auto_now=True, verbose_name="创建时间")
    updateAt = models.DateTimeField(auto_now_add=True, verbose_name="更新时间")

    class Meta:
        managed = True
        db_table = 'HealthLevel'


class ServerLifeScore(models.Model):
    """服务器寿命分数"""
    xid = models.CharField(max_length=128, null=True, blank=True, verbose_name="_XID")
    life = models.CharField(max_length=128, null=True, blank=True, verbose_name="寿命")
    lifeDate = models.CharField(max_length=128, null=True, blank=True, verbose_name="寿命期")
    score = models.IntegerField(null=True, verbose_name="分数")
    weight = models.FloatField(null=True, verbose_name="权重系数")

    createAt = models.DateTimeField(auto_now=True, verbose_name="创建时间")
    updateAt = models.DateTimeField(auto_now_add=True, verbose_name="更新时间")

    class Meta:
        managed = True
        db_table = 'ServerLifeScore'


class FaultFrequencyScore(models.Model):
    """故障频率分数"""
    xid = models.CharField(max_length=128, null=True, blank=True, verbose_name="_XID")
    days = models.CharField(max_length=128, null=True, blank=True, verbose_name="时隔天数")
    frequencyName = models.CharField(max_length=128, null=True, blank=True, verbose_name="频率名称")
    score = models.IntegerField(null=True, verbose_name="频率分数")

    createAt = models.DateTimeField(auto_now=True, verbose_name="创建时间")
    updateAt = models.DateTimeField(auto_now_add=True, verbose_name="更新时间")

    class Meta:
        managed = True
        db_table = 'FaultFrequencyScore'


class FaultScore(models.Model):
    """故障分数"""
    xid = models.CharField(max_length=128, null=True, blank=True, verbose_name="_XID")
    faultType = models.CharField(max_length=128, null=True, blank=True, verbose_name="故障类型")
    faultLevel = models.CharField(max_length=128, null=True, blank=True, verbose_name="故障分级")
    score = models.FloatField(null=True, verbose_name="故障分数")

    createAt = models.DateTimeField(auto_now=True, verbose_name="创建时间")
    updateAt = models.DateTimeField(auto_now_add=True, verbose_name="更新时间")

    class Meta:
        managed = True
        db_table = 'FaultScore'
# Create your models here.
